<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script> 
       function carry(fn)
       {
           return function carried(...args)
           {
               if(args.length>=fn.length)
               {
                  return fn(...args);
               }

               return function(...newArgs)
               {
                  return carried(...args,...newArgs);
               }
           }
       }

       function sum(a,b,c,d,e,f)
       {
         return a+b+c+d+e+f;
       }
       let carrySum = carry(sum);
       console.log(carrySum(1)(2)(3)(4)(5)(6));

    </script>
</body>
</html>